package com.hxm.demo.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestHJ2 {

    /**
     * HJ2 计算某字符出现次数
     *
     * @param args
     */
//    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        // 注意 hasNext 和 hasNextLine 的区别
//        while (in.hasNextLine()) { // 注意 while 处理多个 case
//            char[] a = in.nextLine().toLowerCase().toCharArray();
//            char[] b = in.nextLine().toLowerCase().toCharArray();
//            int length = 0;
//            for (int i = 0; i < a.length; i++) {
//                if (a[i] == b[0]) {
//                    length++;
//                }
//            }
//            System.out.println(length);
//        }
//    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] a = br.readLine().toLowerCase().toCharArray();
        char[] b = br.readLine().toLowerCase().toCharArray();
        int length = 0;
        for (int i = 0; i < a.length; i++) {
            if ((a[i] >= 65 || a[i] < 90) && (a[i] == b[0])) {
                length++;
            }
        }
        System.out.println(length);
    }
}
